package com.xxxx.test;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class test{
   public static void main(String[] args){
        String name = "117";
        String password = "123456";
        final String DBDRIVER = "com.mysql.cj.jdbc.Driver";
        final String DBURL = "jdbc:mysql://localhost:3306/java_tast?serverTimezone=UTC&useSSL=false&characterEncoding=UTF-8";
        final String DBUSER = "root";
        final String DBPASSWORD = "root";
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        String sql = null;
        int s1=0;
        try {
            Class.forName(DBDRIVER);
            conn = DriverManager.getConnection(DBURL, DBUSER, DBPASSWORD);
            stmt = conn.createStatement();
            sql = "UPDATE tb_user set userPwd='"+password+"' WHERE userName='"+name+"'";
            s1 = stmt.executeUpdate(sql);

            rs.close();
            stmt.close();
            conn.close();
            System.out.println(s1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
